package com.gosophia.conferenceManagement.notificationService.test;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.transaction.annotation.Transactional;

import com.gosophia.commons.exception.BusinessException;
import com.gosophia.conferenceManagement.notification.dao.NotificationJobDataDao;
import com.gosophia.conferenceManagement.notification.entity.NotificationJobData;
import com.gosophia.conferenceManagement.notification.service.NotificationService;
import com.gosophia.taskManagement.dao.JobDao;
@ContextConfiguration(locations = { "classpath*:moduleContext.xml",
"classpath:applicationContext-it.xml" })
@Transactional(rollbackFor = { BusinessException.class })
public class ITNotificationServiceImpl  extends AbstractTransactionalJUnit4SpringContextTests{

	@Autowired
	private NotificationService notificationService;
	@Autowired
	private JobDao jobDao;
	@Autowired
	private NotificationJobDataDao notificationJobDataDao;
	/**
	 *  添加通知会议测试1
	 */
	@Test(expected=IllegalArgumentException.class)
	public void testaddNotificationJobDataNULL(){
		notificationService.addNotificationJobData(null);
	}
	
	/**
	 *  添加通知会议测试2
	 */
	@Test(expected=IllegalArgumentException.class)
	public void testaddNotificationJobDataWhithID(){
		NotificationJobData notificationJobData = new NotificationJobData();
		notificationJobData.setJobDataId(1L);
		notificationService.addNotificationJobData(notificationJobData);
	}
	
	/**
	 *  添加通知会议测试3
	 */
	@Test
	public void testaddNotificationJobDataNormal(){
		NotificationJobData notificationJobData = new NotificationJobData();
		notificationJobData.setJob(jobDao.get((1L)));
		notificationJobData.setOpinion("审批通过");
		notificationJobData.setTurningAction("流转");
		notificationJobData.setNotificationType("0");
		notificationService.addNotificationJobData(notificationJobData);
		notificationJobDataDao.flush();
		Assert.assertEquals("审批通过", notificationJobDataDao.getAll().get(0).getOpinion());
		Assert.assertEquals("0",notificationJobDataDao.getAll().get(0).getNotificationType());
	}
	

}
